/*************************************************************************************
* nim.cpp                                                                            *
*                                                                                    *
* This program plays the math game, Nim, over the network (both as client & server). *
*************************************************************************************/
#ifndef NIM_HEADER
#define NIM_HEADER
#include "nim.h";
#endif

#include <winsock.h>
#include <iostream>
using namespace std;

void main(int argc, char* argv[])
{
	int  choice;
	char choice_str[MAX_NAME];
	char newline;

	WORD wVersionRequired = 0x0101;
	WSADATA wsaData;
	int err = WSAStartup(wVersionRequired, &wsaData);
	if (err)
	{
		cout << "Unable to initialize Windows Socket library." << endl;
		return;
	}

	do {
		cout << endl << endl << endl;
		cout << "Do you want to:" << endl;
		cout << "    (1) Host a game" << endl;
		cout << "    (2) Connect to someone else's game?" << endl;
		cout << "    (3) Quit" << endl;
		cout << "Enter 1, 2 or 3: ";
		cin  >> choice_str; cin.get(newline);
		choice = atoi(choice_str);

		if (choice == 1)
			server_main(argc,argv);
		else if (choice == 2)
			client_main(argc,argv);
		else if (choice != 3)
			cout << endl << "Please enter a digit between 1 and 3." << endl;

	} while (choice != 3);
	WSACleanup();
}